package ljl.alg.jianzhioffer.round2;

public class _64_sum_nums {
    
    public int sumNums3(int n) {
        return helper(0, n);
    }
    
    int helper(int sum, int remaining) {
        try {
            // 我这个办法也不是不行。。
            int x = sum / remaining;
        } catch (Exception e) {
            return sum;
        }
        return helper(sum + remaining, remaining - 1);
    }
    
    // 利用短路操作，还是这个快
    int res;
    public int sumNums(int n) {
        boolean x = n > 0 && sumNums(n - 1) > 0;
        res += n;
        return res;
    }
    
}
